body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

/* 顶部导航栏样式 */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: #4a76a8;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    margin: 0px 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0px 50px;
}

#usernameDisplay {
    font-size: 16px;
}
/* 调整聊天容器位置 */
.chat-container {
    margin-top: 70px; /* 为顶部导航栏留出空间 */
    width:800px;
    margin-left: auto;
    margin-right: auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}


.chat-header {
    background: #4a76a8;
    color: white;
    padding: 15px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

/* 聊天消息区域 */
.chat-messages {

    max-width: 800px; /* 限制最大宽度 */
    height: calc(100vh - 180px); /* 自适应高度 */
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 10px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

/* 消息样式调整 */
.message {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 10px;
    max-width: 80%; /* 消息最大宽度 */
}

.user-message {
    background: #e3f2fd;
    margin-left: auto; /* 用户消息靠右 */
    margin-right: 0;
}

.ai-message {
    background: #f1f0f0;
    margin-left: 0;
    margin-right: auto; /* AI消息靠左 */
}

.ai-message .markdown-body {
    color: #cccccc;
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .chat-container {
        background: #2d2d2d;
    }

    .chat-messages {
        background: #1e1e1e;
    }

    .chat-input {
        background: #252525;
    }

    .user-message {
        background: #2a3a4a;
    }
    .ai-message {
        background: #2d2d2d;
    }

    .ai-message .markdown-body {
        color: #e6e6e6;
    }

    .markdown-body th {
        background-color: #3d3d3d;
    }
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #1a2530 100%);
    }

    .auth-container {
        background: #1e2a38;
        box-shadow: 0 0 20px rgba(0,0,0,0.3);
    }

    .form-group label {
        color: #e6e6e6;
    }

    .form-group input {
        background: #2d2d2d;
        border-color: #444;
        color: #e6e6e6;
    }

    .form-group input:focus {
        border-color: #58a6ff;
        box-shadow: 0 0 5px rgba(88, 166, 255, 0.3);
    }

    .auth-tab {
        color: #aaa;
    }

    .auth-tab.active {
        color: #58a6ff;
        border-bottom-color: #58a6ff;
    }
}

/* 输入区域样式 */
#messageInput {
    flex-grow: 1;
}

.chat-input {
    padding: 15px;
    display: flex;
    gap: 10px;
}
/* 响应式设计 */
/* 响应式调整 */
@media (max-width: 1200px) {
    .chat-container {
        max-width: 1000px;
    }

    .chat-messages, .chat-input {
        max-width: 700px;
    }
}

@media (max-width: 1000px) {
    .chat-container {
        max-width: 800px;
    }

    .chat-messages, .chat-input {
        max-width: 100%;
        margin: 0 10px;
    }

    .chat-messages {
        height: calc(100vh - 160px);
    }
}

@media (max-width: 800px) {
    .chat-container {
        margin-top: 50px;
    }

    .chat-messages {
        padding: 10px;
        height: calc(100vh - 150px);
    }

    .chat-input {
        flex-direction: column;
        gap: 10px;
    }

    .chat-input input, .chat-input button {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .chat-container {
        margin-top: 40px;
    }

    .chat-messages {
        padding: 5px;
        height: calc(100vh - 140px);
    }

    .chat-input {
        padding: 10px;
    }
}



input, button {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

button {
    background: #4a76a8;
    color: white;
    cursor: pointer;
}

/* 登录页面样式 */
.login-container {
    width: 400px;
    margin: 100px auto;
    padding: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #4a76a8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

/* 退出按钮样式 */
.logout-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #c0392b;
}
/*用户管理按钮*/
.action-button {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    margin-right: 10px;
}

.action-button:hover {
    background: #2980b9;
}

/* 头部区域样式 */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* 查询表单样式 */
.search-form {
    display: flex;
    gap: 10px;
}

.search-form input, .search-form select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-form button {
    padding: 8px 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.search-form button:hover {
    background: #2980b9;
}

/* 分页控件样式 */
.pagination {
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination button {
    padding: 6px 12px;
    background: #4a76a8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.pagination select {
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Markdown 消息样式 */
.markdown-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    padding: 10px 15px;
    border-radius: 5px;
    background-color: #30475d !important;
}

/* 标题样式 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.25em;
}

/* 段落样式 */
.markdown-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

/* 列表样式 */
.markdown-body ul,
.markdown-body ol {
    padding-left: 2em;
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-body li {
    margin-bottom: 8px;
}

/* 代码块样式 */
.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #2d2d2d;
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(110,118,129,0.4);
    border-radius: 6px;
}

.markdown-body pre code {
    padding: 0;
    margin: 0;
    background: none;
    border-radius: 0;
}

/* 表格样式 */
.markdown-body table {
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
}

.markdown-body th,
.markdown-body td {
    padding: 6px 13px;
    border: 1px solid #ddd;
}

.markdown-body th {
    font-weight: 600;
    background-color: #f6f8fa;
}

/* 引用样式 */
.markdown-body blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
    margin: 0 0 16px 0;
}

/* 链接样式 */
.markdown-body a {
    color: #58a6ff;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

/* 图片样式 */
.markdown-body img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #fff;
    border-radius: 4px;
}

/* 分隔线 */
.markdown-body hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e1e4e8;
    border: 0;
}

/* AI服务选择器样式 */
.ai-service-selector {
    display: flex;
    align-items: center;
    margin-right: 20px;
}

.ai-service-selector label {
    margin-right: 10px;
    color: white;
    font-size: 14px;
}

.ai-service-selector select {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: white;
}

/*/////////////////////////////////////*/
/* 历史对话侧边栏样式 */
.history-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 300px;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #4a76a8;
    color: white;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
}

.toggle-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
}

.search-box {
    padding: 15px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid #ddd;
}

.search-box input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-box button {
    background: #4a76a8;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 15px;
    cursor: pointer;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.3s;
    border-radius: 4px;
}

.history-item:hover {
    background: #e8f4fc;
}

.history-item.active {
    background: #d4e7ff;
    border-left: 4px solid #4a76a8;
}

.history-title {
    font-weight: bold;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.history-title .session-id {
    font-size: 12px;
    color: #777;
    font-weight: normal;
}

.history-time {
    font-size: 12px;
    color: #777;
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .history-sidebar {
        background: #1e1e1e;
        border-right: 1px solid #444;
    }

    .sidebar-header {
        background: #2d2d2d;
    }

    .history-item {
        border-bottom: 1px solid #444;
    }

    .history-item:hover {
        background: #2a3a4a;
    }

    .history-item.active {
        background: #2a3a4a;
        border-left: 4px solid #58a6ff;
    }

    .history-title .session-id {
        color: #aaa;
    }

    .history-time {
        color: #aaa;
    }

    .search-box input {
        background: #2d2d2d;
        border-color: #444;
        color: #e6e6e6;
    }
}

/* 响应式设计 - 小屏幕隐藏侧边栏 */
@media (max-width: 768px) {
    .history-sidebar {
        transform: translateX(-100%);
    }

    .history-sidebar.visible {
        transform: translateX(0);
    }

    .chat-container {
        margin-left: 0;
    }
}

/* 调整主聊天区域 */
.chat-container {
    margin-left: 300px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.top-navbar {
    display: flex;
    align-items: center;
    padding: 0 15px;
    background: #4a76a8;
    color: white;
    height: 60px;
}

.top-navbar .logo {
    flex: 1;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
}

/* 当侧边栏隐藏时调整主区域 */
.history-sidebar.hidden + .chat-container {
    margin-left: 0;
}